package com.hemerasolutions.v2trainer.model.schedule;

import com.hemerasolutions.v2trainer.model.base.BaseModel;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;

@Entity
public class TimeInterval extends BaseModel {

	private static final long serialVersionUID = 1L;

	@Column(length = 20)
	private String name;

	@Column
	private Date begTime;

	@Column
	private Date endTime;

	@Column
	private Date totalTime;
	
	@Column
	private int type;
	
	public final static int TYPE_INTERVAL = 0;
	
	public final static int TYPE_TIME = 1;
	

	public TimeInterval() {
		super();
		this.type = 0;
	}
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public Date getBegTime() {
		return begTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setBegTime(Date begTime) {
		this.begTime = begTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public Date getTotalTime() {
		return totalTime;
	}

	public void setTotalTime(Date totalTime) {
		this.totalTime = totalTime;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((begTime == null) ? 0 : begTime.hashCode());
		result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((totalTime == null) ? 0 : totalTime.hashCode());
		result = prime * result + type;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TimeInterval other = (TimeInterval) obj;
		if (begTime == null) {
			if (other.begTime != null)
				return false;
		} else if (!begTime.equals(other.begTime))
			return false;
		if (endTime == null) {
			if (other.endTime != null)
				return false;
		} else if (!endTime.equals(other.endTime))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (totalTime == null) {
			if (other.totalTime != null)
				return false;
		} else if (!totalTime.equals(other.totalTime))
			return false;
		if (type != other.type)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "TimeInterval [id=" + id + ", name=" + name + ", begTime="
				+ begTime + ", totalTime=" + totalTime + ", endTime=" + endTime
				+ ", type=" + type + "]";
	}

	


}
